import { RouterProvider, createHashRouter } from 'react-router-dom';
import useViewer from './hooks/useViewer';
import AuthPage from './pages/auth/page';
import OrderPage from './pages/order/page';
import UserPage from './pages/user/page';
import HomePage from "./pages/page"
import GoodsPage from './pages/goods/page';
import CommentPage from './pages/comment/page';
import UserMinePage from './pages/user/mine/page';
import ShopPage from './pages/shop/page';
import GoodsMinePage from './pages/goods/mine/page';
import OrderGoodsPage from './pages/order/goods/page';
import CommentGoodsPage from './pages/comment/goods/page';

const router = createHashRouter([{
  path: "/",
  element: <HomePage />
}, {
  path: "/shop",
  element: <ShopPage />
}, {
  path: "/order",
  element: <OrderPage />
}, {
  path: "/user",
  element: <UserPage />
}, {
  path: "/goods",
  element: <GoodsPage />
}, {
  path: "/comment",
  element: <CommentPage />
}, {
  path: "/user/mine",
  element: <UserMinePage />
}, {
  path: "/goods/mine",
  element: <GoodsMinePage />
}, {
  path: "/order/goods",
  element: <OrderGoodsPage />
}, {
  path: "/comment/goods",
  element: <CommentGoodsPage />
}])
function App() {
  const { data, loading } = useViewer()
  if (loading) return <div>loading</div>
  if (!data) return (
    <AuthPage />
  )
  return (
    <div className="App">
      <RouterProvider router={router} />
    </div>
  );
}

export default App;
